<template>
  <div class="width-style">
    <LevelOnePageTop moduleName="现代医学篇" :catagoryList="catagoryList"/>
    <el-row :gutter="20">
      <el-col :span="18">
        <div class="grid-content">
          <InnerModule innerModuleName="指导思想" moduleName="现代医学篇" :list="guideList"  :picSrc="require('@/assets/images/modernMedicalGuide.png')" routeName="/modernmedical/guide"/>
          <InnerModule innerModuleName="诊断方法" moduleName="现代医学篇" :list="diagnosisList"  :picSrc="require('@/assets/images/modernMedicalDiagnosis.png')" routeName="/modernmedical/diagnosis"/>
          <InnerModule innerModuleName="治疗方法" moduleName="现代医学篇" :list="treatmentList" :picSrc="require('@/assets/images/modernMedicalTreatment.jpg')" routeName="/modernmedical/treatment"/>
          <InnerModule innerModuleName="康复指南" moduleName="现代医学篇" :list="nurseList"  :picSrc="require('@/assets/images/modernMedicalNurse.jpg')" routeName="/modernmedical/nurse"/>
        </div>
      </el-col>
      <el-col :span="6">
        <div class="grid-content">
          <ModuleAdviser :doctorList="doctorList"/>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import LevelOnePageTop from '@/components/levelOnePageTop'
import {renderTime} from '@/utils/tools.js'
export default {
  name: "ModernMedical",
  layout: "homeLayout",
  components: { LevelOnePageTop },
  async asyncData({app}) {
    //获取当前类下的最热文章
    let res = await app.api.reqGeneralAllByCatalogue(6);
    if (res.code === 200) {
      for (let item of res.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
     //获取医生等列表
    let doctorRes=await app.api.reqAllDoctor();
    if(doctorRes.code===200){
      for(let doctor of doctorRes.rows){
        doctor.doctorAvatar=app.api.BASEURL+doctor.doctorAvatar
      }
    }
    //获取当类下的子分类的文章
    // let guideRes = await app.api.reqGeneralAllByCatalogue(17);//指导思想
    // if (guideRes.code === 200) {
    //   for (let item of guideRes.rows) {
    //     item.publishTime = renderTime(item.publishTime);
    //   }
    // }
    let guideRes1 = await app.api.reqCoreGeneralByPage(58,1,3);
    let guideRes2 = await app.api.reqCoreGeneralByPage(59,1,3);
    let guideList
    if (guideRes1.code === 200&&guideRes2.code===200) {
      guideList=guideRes1.rows.concat(guideRes2.rows)
      for (let item of guideList) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    // let diagnosisRes = await app.api.reqGeneralAllByCatalogue(18);//诊断方法
    // if (diagnosisRes.code === 200) {
    //   for (let item of diagnosisRes.rows) {
    //     item.publishTime = renderTime(item.publishTime);
    //   }
    // }
    let diagnosisRes1 = await app.api.reqCoreGeneralByPage(61,1,3);
    let diagnosisRes2 = await app.api.reqCoreGeneralByPage(62,1,3);
    let diagnosisRes3 = await app.api.reqCoreGeneralByPage(63,1,3);
    let diagnosisList
    if (diagnosisRes1.code === 200&&diagnosisRes2.code===200&&diagnosisRes3.code===200) {
      diagnosisList=diagnosisRes1.rows.concat(diagnosisRes2.rows,diagnosisRes3.rows)
      for (let item of diagnosisList) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    // let treatmentRes = await app.api.reqGeneralAllByCatalogue(19);//治疗方法
    // if (treatmentRes.code === 200) {
    //   for (let item of treatmentRes.rows) {
    //     item.publishTime = renderTime(item.publishTime);
    //   }
    // }
    let treatmentRes1 = await app.api.reqCoreGeneralByPage(66,1,3);
    let treatmentRes2 = await app.api.reqCoreGeneralByPage(67,1,3);
    let treatmentRes3 = await app.api.reqCoreGeneralByPage(68,1,3);
    let treatmentList
    if (treatmentRes1.code === 200&&treatmentRes2.code===200&&treatmentRes3.code===200) {
      treatmentList=treatmentRes1.rows.concat(treatmentRes2.rows,treatmentRes3.rows)
      for (let item of treatmentList) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    let nurseRes = await app.api.reqCoreGeneralByPage(20,1,5);//康复指南
    if (nurseRes.code === 200) {
      for (let item of nurseRes.rows) {
        item.publishTime = renderTime(item.publishTime);
      }
    }
    return {
      catagoryList:res.rows,
      doctorList:doctorRes.rows,
      // guideList:guideRes.rows,
      guideList,
      // diagnosisList:diagnosisRes.rows,
      diagnosisList,
      // treatmentList:treatmentRes.rows,
      treatmentList,
      nurseList:nurseRes.rows,
    }
  },
};
</script>

<style scoped lang="less">
.el-row {
  margin-bottom: 20px;
  &:last-child {
    margin-bottom: 0;
  }
}
.grid-content {
  min-height: 36px;
}
.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}
.module-name {
  font-size: 20px;
  .icon-traditional {
    font-size: 24px;
    color: @themeColor;
  }
}
.modern-medical-img {
  width: 100%;
  height: 100%;
}
</style>
